package cn.conchit.apccontroldemo.graph.canvas;

import cn.conchit.apccontroldemo.graph.cmpt.CGateInCmpt;
import cn.conchit.apccontroldemo.graph.cmpt.CGateOutCmpt;
import cn.conchit.apccontroldemo.graph.cmpt.MpcCmpt;
import cn.conchit.apccontroldemo.graph.cmpt.PythonCmpt;

/**
 * @author hetao
 * @version 1.0
 * @description: TODO
 * @date 2023/2/16 14:13
 */
public class CmptFactory {


    /**
     * @description: 这部分代码暂时这么写，后期再改
     * @param: v
     * @return: cn.conchit.apccontroldemo.graph.canvas.CmptNode<V>
     * @author hetao
     * @date: 2023/2/16 16:16
     */
    public static <V extends CmptVertex> CmptNode<V> createNode(V v) {
        String type = v.getCmpt().getType();
        if(type.equals("cgatein")) {
            return new CGateInCmpt(v);
        } else if(type.equals("python")) {
            return new PythonCmpt(v);
        } else if(type.equals("mpc")) {
            return new MpcCmpt(v);
        } else if(type.equals("cgateout")) {
            return new CGateOutCmpt<>(v);
        }
        return null;
    }

}
